import 'package:twelve_animals/widgets/avatar.dart';
import 'package:flutter/material.dart';

class Info extends StatefulWidget {
  Info({Key key, this.sex, this.onTap, this.constellation}) : super(key: key);
  final int sex;
  final onTap;
  final constellation;

  @override
  _InfoState createState() => _InfoState();
}

class _InfoState extends State<Info> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    Color mainColor = widget.sex == 1 ? Color(0xFF478FC2) : Color(0xFFF88686);
    return Column(
      crossAxisAlignment: CrossAxisAlignment.center,
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Avatar(sex: widget.sex, index: widget.constellation['id']),
        SizedBox(height: 15),
        Text(
          widget.constellation['name'],
          style: TextStyle(
            fontSize: 17,
            fontWeight: FontWeight.w400,
            color: mainColor,
          ),
        ),
        SizedBox(height: 10),
        Row(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            InkWell(
              onTap: widget.onTap,
              child: Container(
                padding: EdgeInsets.fromLTRB(15, 5, 15, 5),
                decoration: BoxDecoration(
                  border: Border.all(color: mainColor, width: 1),
                  color: mainColor.withOpacity(0.2),
                  borderRadius: BorderRadius.circular(20),
                ),
                child: Center(
                  child: Text(
                    "点击选择${widget.sex == 1 ? "男" : "女"}生属相",
                    style: TextStyle(
                      color: mainColor,
                      fontSize: 12,
                      fontWeight: FontWeight.w700,
                    ),
                  ),
                ),
              ),
            ),
          ],
        ),
      ],
    );
  }
}
